package cn.bytecollege.admin.controller;

import cn.bytecollege.admin.service.CartService;
import cn.bytecollege.common.constant.Resource;
import cn.bytecollege.common.entity.Cart;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "CartListController", value = "/admin/cartList")
public class CartListController extends HttpServlet {
    private CartService cartService = null;
    public CartListController(){
        cartService = new CartService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Cart> list = cartService.find();
        request.setAttribute("list",list);
        request.getRequestDispatcher(Resource.PAGE_LOCATION+"/admin/cartList.jsp").forward(request,response);
    }
}
